import { ConfigEnv, defineConfig, UserConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteMockServe } from 'vite-plugin-mock'
// https://vitejs.dev/config/
export default ({ command, mode }: ConfigEnv): UserConfig => {
  return {
    plugins: [vue(), viteMockServe({
      // eslint-disable-next-line no-useless-escape
      ignore: /^\_/,
      mockPath: 'mock',
      localEnabled: !(command === 'build'),
      prodEnabled: command === 'build',
      injectCode: `
      import { setupProdMockServer } from '../mock/_createProductionServer';

      setupProdMockServer();
      `
    }),],
  }
}
